package com.ah.cookie.autologin;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ah.util.Const;
@WebServlet("/ServletCancelAutoLogin")
public class C3ServletCancelAutoLogin extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 取消自动登录
		Cookie[] cookies = request.getCookies();
		for (Cookie cookie : cookies) {
			String ckName = cookie.getName();
			if ("uname".equals(ckName) || "pwd".equals(ckName)) {
				cookie.setMaxAge(0);
				cookie.setPath("/");
				response.addCookie(cookie);
			}
		}
		response.sendRedirect(Const.P_LOGIN);
	}
}
